﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace BlueRoseGames.Controls.Text
{
    public class SineTransform : Transform
    {
        #region DependencyProperties

        public static readonly DependencyProperty AmplitudeProperty = Register("Amplitude", typeof(double), typeof(SineTransform), 0d);
        public double Amplitude
        {
            get { return (double)GetValue(AmplitudeProperty); }
            set { SetValue(AmplitudeProperty, value); }
        }

        public static readonly DependencyProperty PeriodProperty = Register("Period", typeof(double), typeof(SineTransform), 50d);
        public double Period
        {
            get { return (double)GetValue(PeriodProperty); }
            set { SetValue(PeriodProperty, value); }
        }

        public static readonly DependencyProperty StartAngleProperty = Register("StartAngle", typeof(double), typeof(SineTransform), 0d);
        public double StartAngle
        {
            get { return (double)GetValue(StartAngleProperty); }
            set { SetValue(StartAngleProperty, value); }
        }

        #endregion

        public override Point TransformPoint(Point p)
        {
            Point ret = new Point();
            double angle = ((p.X / Period) + (StartAngle / 360d)) * Math.PI * 2;
            ret.X = p.X;
            ret.Y = Math.Sin(angle) * Amplitude + p.Y;
            return ret;
        }
    }
}
